//
//  BrandViewController.m
//  quxiangtao
//
//  Created by xbmios on 2018/7/24.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "BrandViewController.h"

#import "DiscoveryBrandTableViewCell.h"

static NSString *brandContentCellID = @"brandContentCellID";

@interface BrandViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (strong, nonatomic) UITableView *brandTableView;


@end

@implementation BrandViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = Colorf2f2f2;
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.title = @"发现大牌";

    [self createUI];
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    
    return jisuan(20);
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    return jisuan(0.0000001);
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return jisuan(500);
}

#pragma mark -delegate \ datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 5;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    DiscoveryBrandTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:brandContentCellID];
    
    if (!cell) {
        
        cell = [[DiscoveryBrandTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:brandContentCellID];
    }
    
    cell.parentVC = self;
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (void)createUI {
    
    [self.view addSubview:self.brandTableView];
    __weak typeof(self) weakSelf = self;
    [self.brandTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left);
        make.right.mas_equalTo(weakSelf.view.mas_right);
        make.top.mas_equalTo(weakSelf.view.mas_top);
        make.bottom.mas_equalTo(weakSelf.view.mas_bottom);
        
    }];
    
}

#pragma mark -lazy
- (UITableView *)brandTableView {
    
    if (!_brandTableView) {
        
        _brandTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        
        _brandTableView.delegate = self;
        _brandTableView.dataSource = self;
        
        _brandTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        _brandTableView.showsVerticalScrollIndicator = NO;
        _brandTableView.showsHorizontalScrollIndicator = NO;
        
        _brandTableView.estimatedRowHeight = 0;
        _brandTableView.estimatedSectionFooterHeight = 0;
        _brandTableView.estimatedSectionHeaderHeight = 0;
        
        if (@available(iOS 11.0, *)) {
            
            _brandTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
            
        }
        
    }
    
    return _brandTableView;
}

#pragma mark -设置
- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.hidden = NO;
//    self.tabBarController.tabBar.hidden = YES;
    
}

- (void)viewWillDisappear:(BOOL)animated {
    
    [super viewWillDisappear:animated];
    
//    self.navigationController.navigationBar.hidden = NO;
//    self.tabBarController.tabBar.hidden = NO;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
